/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.OptionalInt;
import java.util.stream.IntStream;

/**
 * <p>Project: jse2204 - Stream3
 * <p>Powered by webrx On 2022-09-28 16:18:27
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Stream3 {
    public static void main(String[] args) {

        //集合类 1 2 -> 3 + 3 -> 6 +4  求1+2+3+...+100的和
        OptionalInt op = IntStream.rangeClosed(1,100).reduce((a, b)->a+b);
        int n = op.getAsInt();
        System.out.println(n);

        //求阶乘 1*2*3
        int jc3 = IntStream.rangeClosed(1, 3).reduce((a, b) -> a * b).getAsInt();
        System.out.println(jc3);
        System.out.println(1*2*3);

    }
}
